package com.example.demo.serviceImpl;

import com.example.demo.bean.Account;
import com.example.demo.bean.ClassGrade;
import com.example.demo.dao.AccountDAO;
import com.example.demo.service.AccountService;

public class AccountServiceImpl implements AccountService {
    private AccountDAO accountDAO;
//    public boolean isExist(String account_num) {
//        Account account = getByName(account_num);
//        return null!= account;
//    }
//
//    public Account getByName(String account_num) {
//        return accountDAO.findByUsername(account_num);
//    }

    public Account get(String account_num, String password){
        return accountDAO.getByAccount_numAndPassword(account_num, password);
    }

    public Boolean addAccount(Account account) {
        int count=accountDAO.insertAccount(account);
        if(count>0){
            return true;
        }
        return false;
    }
    public Boolean updateAccount(Account accountToUpdate,Account newAccount){
        int count=accountDAO.updateAccount(accountToUpdate,newAccount);
        if(count>0){
            return true;
        }
        return false;
    }
    public Boolean deleteAccount(Account account){
        int count=accountDAO.deleteAccount(account);
        if(count>0){
            return true;
        }
        return false;

    }
    public Boolean setHeadTeacher(Account account, ClassGrade classGrade){
        int count=accountDAO.setHeadTeacher(account,classGrade);
        if(count>0){
            return true;
        }
        return false;
    }

}
